def select_sort(lst: list):
    """
    选择排序：选择(0, i-1)位置的最大值与i位置做交换
    :param lst:
    :return:
    """
    if not lst or len(lst) < 2:
        return
    for i in range(len(lst)):
        tmp = 0
        for j in range(0, len(lst)-i):
            if lst[j] > lst[tmp]:
                tmp = j
        lst[tmp], lst[len(lst)-i-1] = lst[len(lst)-i-1], lst[tmp]


if __name__ == "__main__":
    lst = [2, 4, 1, 5, 3, 9, 7]
    select_sort(lst)
    print(lst)
